// import { getPermissionOption } from '/@/api/sys/permission';
import { getMenuTreeOption } from '@/api/sys/menu';

// 数据库表单
export function getDatabaseForm(): (
  | {
      colProps: { span: number };
      component: string;
      field: string;
      label: string;
      helpMessage: string[];
      required: boolean;
    }
  | {
      colProps: { span: number };
      component: string;
      field: string;
      label: string;
      required: boolean;
      helpMessage: string[];
    }
  | {
      colProps: { span: number };
      itemProps: { wrapperCol: {}; labelCol: {} };
      component: string;
      field: string;
      componentProps: {};
      label: string;
      required: boolean;
      helpMessage: any[];
    }
  | {
      colProps: { span: number };
      itemProps: { wrapperCol: {}; labelCol: {} };
      component: string;
      field: string;
      defaultValue: string;
      componentProps: {};
      label: string;
      required: boolean;
      helpMessage: string[];
    }
  | {
      colProps: { span: number };
      component: string;
      field: string;
      defaultValue: string;
      componentProps: {
        onOptionsChange: (options) => void;
        onChange: (e) => void;
        resultField: string;
        api: any;
        valueField: string;
        labelField: string;
      };
      label: string;
      helpMessage: string[];
      required: boolean;
    }
  | {
      colProps: { span: number };
      itemProps: { wrapperCol: {}; labelCol: {} };
      component: string;
      field: string;
      defaultValue: string;
      componentProps: { options: { label: string; value: string }[] };
      label: string;
      required: boolean;
      helpMessage: string[];
    }
  | {
      colProps: { span: number };
      component: string;
      field: string;
      componentProps: {
        onOptionsChange: (options) => void;
        onChange: (e) => void;
        resultField: string;
        api: (params) => any;
        valueField: string;
        labelField: string;
      };
      label: string;
      helpMessage: string[];
      required: boolean;
    }
  | {
      colProps: { span: number };
      component: string;
      field: string;
      defaultValue: string[];
      componentProps: {
        mode: string;
        onChange: (value) => void;
        options: { label: string; value: string; key: string }[];
      };
      label: string;
      helpMessage: string[];
    }
)[] {
  return [
    {
      field: 'controller_name',
      component: 'Input',
      label: '控制器名称',
      helpMessage: [
        '如果是两个及两个以上单词，请用小驼峰来书写 例如 userLoginLog',
        '表名会将小驼峰用_分开 例如：userLoginLog ——> user_login_log',
      ],
      required: true,
      colProps: {
        span: 12,
      },
    },
    {
      field: 'controller_comment',
      component: 'Input',
      label: '控制器备注',
      required: true,
      colProps: {
        span: 12,
      },
      helpMessage: ['控制器注释', '表注释'],
    },
    {
      component: 'IconPicker',
      label: '图标选择',
      colProps: {
        span: 12,
      },
      field: 'icon',
      componentProps: {},
      itemProps: {
        labelCol: {},
        wrapperCol: {},
      },
      required: true,
      helpMessage: ['图标参考注意事项第四条'],
    },
    {
      component: 'InputNumber',
      label: '菜单排序',
      colProps: {
        span: 12,
      },
      field: 'order_no',
      componentProps: {},
      itemProps: {
        labelCol: {},
        wrapperCol: {},
      },
      required: true,
      defaultValue: '9999999',
      helpMessage: ['数值越大越靠后', '只对一级菜单有效'],
    },
    {
      field: 'pid',
      component: 'ApiTreeSelect',
      label: '目录父级',
      helpMessage: ['选择权限上级'],
      componentProps: {
        api: getMenuTreeOption,
        // 展示的名字
        labelField: 'name',
        // 展示的值
        valueField: 'id',
        onChange: (e) => {
          console.log('selected:', e);
        },
        // atfer request callback
        onOptionsChange: (options) => {
          console.log('get options', options.length, options);
        },
      },
      required: true,
      colProps: {
        span: 12,
      },
    },
    {
      field: 'function',
      component: 'Select',
      label: '可选功能',
      helpMessage: ['选择模块所需要的功能，查询是必要的，不能选择'],
      colProps: {
        span: 12,
      },
      componentProps: {
        mode: 'multiple',
        options: [
          {
            label: '新增',
            value: '1',
            key: '1',
          },
          {
            label: '编辑',
            value: '2',
            key: '2',
          },
          {
            label: '删除',
            value: '3',
            key: '3',
          },
          {
            label: 'Excel导入',
            value: '4',
            key: '4',
          },
          {
            label: 'Excel导出',
            value: '5',
            key: '5',
          },
          // {
          //   label: '启用观察者模式',
          //   value: '6',
          //   key: '6',
          // },
          // {
          //   label: '启用消息队列（异步处理，请配置好RabbitMQ）',
          //   value: '7',
          //   key: '7',
          // },
        ],
        onChange: (value) => {
          console.log(value, '123');
        },
      },
      defaultValue: ['1', '2', '3'],
    },
  ];
}
